Skip to content

Add option to keep original tab open on container switch#17

Open
tomludd wants to merge 2 commits intoicholy:masterfrom
tomludd:master
Open

Add option to keep original tab open on container switch#17
tomludd wants to merge 2 commits intoicholy:masterfrom
tomludd:master

Conversation

@tomludd
Copy link

@tomludd tomludd commented Mar 6, 2026

Hey! I really like your extension, and I found one thing I wanted to improve on:
When ContainerScript redirects a URL into a different container, the original tab is always closed. This can be disruptive when the user is navigating from an existing page — they lose that page's context and history. However, if the user just opened a fresh new tab (e.g. about:newtab), closing it is the expected behavior.

Solution
This PR adds a "Keep original tab open on container switch" checkbox to the editor UI. When enabled, the original tab is preserved after the new container tab is created. Blank/new tabs (about:newtab, about:blank, about:home) are always closed regardless of the setting, since keeping an empty tab around serves no purpose.

Now when I do a google search and click a link the google search tab will no longer close, but a new tab is opened with correct container.

@icholy
Copy link
Owner

icholy commented Mar 6, 2026

What if we added replace option to ContainerInfo here

interface ContainerInfo {
name: string | null;
icon?: string;
color?: string;
}

Then you could chose the behaviour per-container:

if (url.hostname === "www.google.ca") {
	return {
		name: "Search",
		replace: false,
	}
}

@tomludd
Copy link
Author

tomludd commented Mar 6, 2026

I struggle to see how this would help. As this would make the feature close my google search tab depending on what container the clicked link was opened in.

May be a rule list for what domains to keep open?
I'll put it together quickly, then you can see if you like it.

@icholy
Copy link
Owner

icholy commented Mar 6, 2026

Hmm ok, seems like I'm not grasping your use-case. Can you walk me through a realistic step by step scenario?

@tomludd
Copy link
Author

tomludd commented Mar 6, 2026

Will do! So mostly this is a problem that happens when I navigate back and forth between websites, searching mostly. Many answers are found on reddit, so I click that link. Now, Reddit is connected to my personal container while Google is not. When reddit is opened in a new container tab the history is lost. The result is I can no longer navigate back to the search I came from. Reopening recently closed tab is the only way of getting back to the previous page.

Now the best solution would be to rewrite the histroy for the tab but that seems impossible at the moment. So keeping the tab open in some cases seems like the second best solution.

I've updated the code now with replace as suggested I also added sourceUrl that can be used to decide if tab should be replaced or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants